/*
 * Copyright 2005-2013 finalist.cn. All rights reserved.
 * Support: http://www.finalist.cn
 * License: http://www.finalist.cn/license
 */
package com.finalist.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.finalist.dao.AreaDao;
import com.finalist.entity.Area;
import com.finalist.service.AreaService;

/**
 * Service - 地区
 * 
 * @author Finalist IT Group
 * @version 3.0
 */
@Service("areaServiceImpl")
public class AreaServiceImpl extends BaseServiceImpl<Area, Long> implements AreaService
{

    @Resource(name = "areaDaoImpl")
    private AreaDao areaDao;

    @Resource(name = "areaDaoImpl")
    public void setBaseDao(AreaDao areaDao)
    {
        super.setBaseDao(areaDao);
    }

    @Transactional(readOnly = true)
    public List<Area> findRoots()
    {
        return areaDao.findRoots(null);
    }

    @Transactional(readOnly = true)
    public List<Area> findRoots(Integer count)
    {
        return areaDao.findRoots(count);
    }

    @Override
    @Transactional
    @CacheEvict(value = "area", allEntries = true)
    public void save(Area area)
    {
        super.save(area);
    }

    @Override
    @Transactional
    @CacheEvict(value = "area", allEntries = true)
    public Area update(Area area)
    {
        return super.update(area);
    }

    @Override
    @Transactional
    @CacheEvict(value = "area", allEntries = true)
    public Area update(Area area, String... ignoreProperties)
    {
        return super.update(area, ignoreProperties);
    }

    @Override
    @Transactional
    @CacheEvict(value = "area", allEntries = true)
    public void delete(Long id)
    {
        super.delete(id);
    }

    @Override
    @Transactional
    @CacheEvict(value = "area", allEntries = true)
    public void delete(Long... ids)
    {
        super.delete(ids);
    }

    @Override
    @Transactional
    @CacheEvict(value = "area", allEntries = true)
    public void delete(Area area)
    {
        super.delete(area);
    }

    @Override
    public List<Area> findChildrens(Long parentId)
    {
        return areaDao.findChildrens(parentId);
    }

    @Override
    public Area findAreaById(Long id)
    {
        return areaDao.findAreaById(id);
    }

    @Override
    public Area findAreaByTreePathAndName(String treePath, String name)
    {
        return areaDao.findAreaByTreePathAndName(treePath, name);
    }

    // @Override
    // public List<Area> findByTreepath(Member member, String treePath) {
    // return areaDao.findByTreepath(member, treePath);
    // }

}